class_name HitboxComponent
extends Area2D


signal hit_hurtbox(hurtbox: HurtboxComponent)

## 伤害
var damage: int = 1
## 暴击
var critical: bool = false
## 击退力量
var knockback_power: float = 0.0
## 受组件影响的目标
var source: Node2D



func _ready():
	source = owner as Node2D
	area_entered.connect(_on_hit_area)


func _on_hit_area(area: Area2D):
	prints("====== on_hit_area")


	if area is HurtboxComponent:
		hit_hurtbox.emit(area)



func setup(damage_: int):
	self.damage = damage_


func set_enabled(enable: bool):
	set_deferred("monitoring", enable)
	set_deferred("monitorable", enable)
